<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>流光按钮效果</title>
</head>
<body>
    <div class="container">
        <button class="button">
            <span class="button-text">流光按钮</span>
        </button>
    </div>
</body>
</html>

<style>
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    body {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        font-family: 'Microsoft YaHei', Arial, sans-serif;
    }

    .container {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
    }

    .button {
        position: relative;
        width: 300px;
        height: 100px;
        background-color: #ac2a2a;
        border: none;
        border-radius: 12px;
        cursor: pointer;
        overflow: hidden;
        transition: transform 0.3s ease;
    }

    .button:hover {
        transform: scale(1.05);
    }

    .button:active {
        transform: scale(0.98);
    }

    /* 流光效果 */
    .button::before {
        content: '';
        position: absolute;
        top: -50%;
        left: -50%;
        width: 200%;
        height: 200%;
        /* 使用conic-gradient开启圆形渐变 */
        background: conic-gradient(
            transparent,
            transparent,
            transparent,
            #00ccff,
            #d400d4,
            #ff00ff,
            transparent,
            transparent
        );
        animation: glow 4s linear infinite;
    }

    /* 内层遮罩，显示按钮背景 */
    .button::after { 
        content: '';
        position: absolute;
        /* 
        inset: 4px;表示内边距为4px,相当于top: 4px;left: 4px;right: 4px;bottom: 4px;自动设置了宽高
        使用宽高的话需要手动计算得到具体的宽高值以及留出流光边框的空间
        */
        inset: 4px;
        background-color: #000;
        border-radius: 10px;
        z-index: 1;
    }

    /* 按钮文字 */
    .button-text {
        position: relative;
        z-index: 2;
        color: #fff;
        font-size: 20px;
        font-weight: bold;
        letter-spacing: 2px;
        text-transform: uppercase;
    }

    @keyframes glow {
        0% {
            transform: rotate(0deg);
        }
        100% {
            transform: rotate(360deg);
        }
    }

    /* 悬停时增强发光效果 */
    .button:hover::before {
        animation: glow 2s linear infinite;
    }

    /* 添加额外的光晕效果 */
    .button:hover {
        box-shadow: 0 0 20px rgba(0, 204, 255, 0.5),
                    0 0 40px rgba(212, 0, 212, 0.3),
                    0 0 60px rgba(255, 0, 255, 0.2);
    }
</style>